package hyy_2022;


/**
 * 给定一个整数columnNumber, 返回它在excel表中相应的列名称
 * A -> 1
 * B -> 2
 * C -> 3
 * ...
 * Z -> 26
 * AA -> 27
 * AB -> 28
 *
 */
public class _0818_168_NumberToTitle {

    public String numberToTitle(int columnNumber) {
        StringBuffer sb = new StringBuffer();
        while(columnNumber > 0) {
            int a0 = (columnNumber - 1) % 26 + 1;
            sb.append((char) (a0 - 1 + 'A'));
            columnNumber = (columnNumber - a0) / 26;
        }
        return sb.reverse().toString();
    }
}
